<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<html>
<head>
    <title>ИС "Аттестация рабочих мест"</title>
    <link rel="stylesheet" type="text/css" href="/arm/resources/css/style.css">
</head>
<body>


<f:view>
    <a4j:form ajaxSubmit="true">

        <%@ include file="/pages/common/menu.jsp" %>

        <rich:dataTable
                id="metTbl"
                cellpadding="0" cellspacing="0"
                width="700" border="0"
                value="#{metricBean.tableManager.list}"
                var="row"
                onRowClick="selectRow( '#{row.id}' )"
                rowClasses="#{metricBean.tableManager.rowClasses}"
                >

            <rich:column>
                <f:facet name="header">
                    <h:outputText value="Наименование объекта" />
                </f:facet>
                <h:outputText value="#{row.obiekt.name}"/>
            </rich:column>

            <rich:column>
                <f:facet name="header">
                    <h:outputText value="Наименование периода" />
                </f:facet>
                <h:outputText value="#{row.dicPeriod.name}"/>
            </rich:column>

            <rich:column>
                <f:facet name="header">
                    <h:outputText value="Наименование должности" />
                </f:facet>
                <h:outputText value="#{row.dicPost.name}"/>
            </rich:column>

            <rich:column>
                <f:facet name="header">
                    <h:outputText value="Вид измерения" />
                </f:facet>
                <h:outputText value="#{row.dicMetricType.name}"/>
            </rich:column>

            <rich:column>
                <f:facet name="header">
                    <h:outputText value="Категория" />
                </f:facet>
                <h:outputText value="#{row.dicCategory.name}"/>
            </rich:column>

            <rich:column>
                <f:facet name="header">
                    <h:outputText value="Значения" />
                </f:facet>
                <h:outputText value="#{row.value}"/>
            </rich:column>

            <rich:column>
                <f:facet name="header">
                    <h:outputText value="Количество рабочих мест" />
                </f:facet>
                <h:outputText value="#{row.numberWorkplace}"/>
            </rich:column>

            <rich:column>
                <f:facet name="header">
                    <h:outputText value="Код рабочего места" />
                </f:facet>
                <h:outputText value="#{row.keyWorkplace}"/>
            </rich:column>

        </rich:dataTable>

        <a4j:jsFunction name="selectRow" reRender="metTbl, metEdit, metDelete" ignoreDupResponses="true">
            <a4j:actionparam name="rowIndex" assignTo="#{metricBean.tableManager.selectedId}"/>
        </a4j:jsFunction>


        <a4j:commandButton action="#{metricBean.create}" value="Создать"/>
        <a4j:commandButton id="metEdit"
                           action="#{metricBean.edit}"
                           value="Редактировать"
                           disabled="#{not metricBean.tableManager.selected}">
        </a4j:commandButton>
        <a4j:commandButton id="metDelete"
                           action="#{metricBean.delete}"
                           value="Удалить"
                           reRender="metTbl"
                           disabled="#{not metricBean.tableManager.selected}"/>
        <a4j:commandButton action="main" value="Назад"/>
    </a4j:form>
</f:view>
</body>
</html>